<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php');

/**
 * UsuarioCredito filter form base class.
 *
 * @package    filters
 * @subpackage UsuarioCredito *
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 11675 2008-09-19 15:21:38Z fabien $
 */
class BaseUsuarioCreditoFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'tp_finalidade'      => new sfWidgetFormFilterInput(),
      'tp_garantia'        => new sfWidgetFormFilterInput(),
      'vl_solicitado'      => new sfWidgetFormFilterInput(),
      'vl_maximo'          => new sfWidgetFormFilterInput(),
      'vl_parcela'         => new sfWidgetFormFilterInput(),
      'dt_prazo'           => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'ds_carencia'        => new sfWidgetFormFilterInput(),
      'id_dados_usuario'   => new sfWidgetFormDoctrineChoice(array('model' => 'DadosUsuario', 'add_empty' => true)),
      'created_at'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'updated_at'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
    ));

    $this->setValidators(array(
      'tp_finalidade'      => new sfValidatorPass(array('required' => false)),
      'tp_garantia'        => new sfValidatorPass(array('required' => false)),
      'vl_solicitado'      => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'vl_maximo'          => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'vl_parcela'         => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'dt_prazo'           => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'ds_carencia'        => new sfValidatorPass(array('required' => false)),
      'id_dados_usuario'   => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'DadosUsuario', 'column' => 'id_dados_usuario')),
      'created_at'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('usuario_credito_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'UsuarioCredito';
  }

  public function getFields()
  {
    return array(
      'id_usuario_credito' => 'Number',
      'tp_finalidade'      => 'Text',
      'tp_garantia'        => 'Text',
      'vl_solicitado'      => 'Number',
      'vl_maximo'          => 'Number',
      'vl_parcela'         => 'Number',
      'dt_prazo'           => 'Date',
      'ds_carencia'        => 'Text',
      'id_dados_usuario'   => 'ForeignKey',
      'created_at'         => 'Date',
      'updated_at'         => 'Date',
    );
  }
}